import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { AddLinkTeacherData, AddTeacherData } from "./types";

/**
 * 添加学生 生成链接
 *
 * @param queryParams
 */
export function AddLinkTeacher(
  queryParams: AddLinkTeacherData,
  courseId: number
): AxiosPromise<string> {
  return request({
    url: "/api/v1/system/course/teacherLink",
    method: "get",
    params: {
      ...queryParams,
      courseId,
    },
  });
}

/**
 * 添加教师 直接添加
 *
 * @param queryParams
 */
export function DirectAddTeacher(
  queryParams: AddTeacherData,
  courseId: number
): AxiosPromise<string> {
  return request({
    url: "/api/v1/system/course/addTeacher",
    method: "post",
    params: {
      ...queryParams,
      courseId,
    },
  });
}

/**
 * 删除教师权限
 *
 * @param queryParams
 */
export function deleteTeacherRole(id: number, courseId: number) {
  return request({
    url: `/api/v1/system/course/deleteTeacher/${id}`,
    method: "delete",
    params: {
      courseId,
    },
  });
}

/**
 * 删除教师权限
 *
 * @param queryParams
 */
export function changeTeacherRole(
  roleId: number,
  userId: number,
  courseId: number
) {
  return request({
    url: `/api/v1/system/course/updateRole/${userId}`,
    method: "patch",
    params: {
      roleId,
      courseId,
    },
  });
}
